package com.ssyc.gsk_teacher.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.makeramen.roundedimageview.RoundedImageView;
import com.ssyc.common.glide.ImageUtil;
import com.ssyc.common.view.StarBar;
import com.ssyc.gsk_teacher.R;
import com.ssyc.gsk_teacher.bean.EvaluateInfo;

import java.util.List;

/**
 * 评价老师列表适配器
 * Created by Administrator on 2018/6/20 0020.
 */

public class EvaluateRvAdapter extends BaseQuickAdapter<EvaluateInfo.DataBean.PeComtentBean, BaseViewHolder> {
    private Context context;


    public EvaluateRvAdapter(Context context, int layoutResId, @Nullable List<EvaluateInfo.DataBean.PeComtentBean> data) {
        super(layoutResId, data);
        this.context = context;
    }


    @Override
    protected void convert(BaseViewHolder helper, EvaluateInfo.DataBean.PeComtentBean item) {
        //头像
        RoundedImageView headImg = helper.getView(R.id.iv_head);

        //电话
        TextView tvTel = helper.getView(R.id.tv_tel);

        //时间
        TextView tvTime = helper.getView(R.id.tv_time);

        //星级控件
        StarBar bar = helper.getView(R.id.bar);
        bar.setEnabled(false);


        //设置等级
        bar.setStarMark((float) Integer.parseInt(item.getPe_grade()));

        //家长评语
        TextView tvContent = helper.getView(R.id.tv_content);

        //设置头像
        ImageUtil.displayImage(context,headImg,item.getPe_url(),R.drawable.base_default_head);

        //设置电话
        tvTel.setText(item.getPe_phone().substring(0,3)+"*****"+item.getPe_phone().substring(8,11));

        //设置时间
        tvTime.setText(item.getPe_time());

        //设置评语
        tvContent.setText(item.getPe_content());

    }
}
